package com.edu.contorller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
public class ServletTest {


    @RequestMapping("/servletTest")
    public void headerTest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        ServletContext application = request.getSession().getServletContext();
        session.setAttribute("loginUser","zhangsan");
        application.setAttribute("num",1);
//        request.getRequestDispatcher("index.jsp").forward(request,response);
        String str = null;
        System.out.println(str.length());
        response.sendRedirect("index.jsp");
    }

}
